import 'dart:typed_data';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:landlore/customWidget/recordBodyCheckIn.dart';
import 'package:landlore/customWidget/recordBodyCheckOut.dart';
import 'package:landlore/dbUtil/databaseHelper.dart';
import 'package:landlore/screens/roomEditScreen.dart';
import 'package:path_provider/path_provider.dart';
import 'package:screenshot/screenshot.dart';
import 'package:share_plus/share_plus.dart';

import '../customWidget/recordBody.dart';
import '../model/orderVO.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

// import 'package:gallery_saver/gallery_saver.dart';
import 'dart:io';

import '../model/roomCheckInOut.dart';
import '../model/roomInfo.dart';

/***
 * 入住/退房 登记出单页面
 */
class OutputBillCheckInOutDisplayScreen extends StatefulWidget {
  final RoomCheckInOut roomCheckInOutVO;

  OutputBillCheckInOutDisplayScreen({
    super.key,
    required this.roomCheckInOutVO,
  });

  @override
  State<OutputBillCheckInOutDisplayScreen> createState() =>
      _OutputBillCheckInOutDisplayScreenState();
}

class _OutputBillCheckInOutDisplayScreenState
    extends State<OutputBillCheckInOutDisplayScreen> {
  RoomCheckInOut? roomCheckInOutVO;

  @override
  initState() {
    roomCheckInOutVO = widget.roomCheckInOutVO;
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MediaQuery(
      ///设置文字大小不随系统设置改变
      data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
      child: Scaffold(
        appBar: AppBar(
          backgroundColor: const Color(0xffe9c46a),
          leading: IconButton(
            icon: Icon(
              Icons.arrow_back_ios,
              size: 35.sp,
              color: Colors.black,
            ),
            onPressed: () => Navigator.pop(context),
          ),
        ),
        body: Container(
            color: Colors.grey,
            child: ListView(
              children: roomCheckInOutVO == null
                  ? []
                  : [
                roomCheckInOutVO!.state == 1
                    ? RecordBodyCheckIn(
                  orderVO: roomCheckInOutVO!,
                  callback: (result) {
                    setState(() {
                      roomCheckInOutVO = result;
                    });
                  },
                )
                    : RecordBodyCheckOut(
                  orderVO: roomCheckInOutVO!,
                  callback: (result) {
                    setState(() {
                      roomCheckInOutVO = result;
                    });
                  },
                ),
              ],
            )),
      ),
    );
  }
}
